Fixed internal styles so -i -f -f works as expected
authorparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 17 Sep 2004 21:04:23 +0000 (21:04 +0000)
committerparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 17 Sep 2004 21:04:23 +0000 (21:04 +0000)
gpsbabel/defs.h
gpsbabel/vecs.c
gpsbabel/xcsv.c

index cf4ad1c368095d5c9f4d32d181eea3f0791c2635..21fa18ae22d9e970d5296093977f6f882f81b85b 100644 (file)
@@ -263,6 +263,7 @@ void waypt_flush(queue *);
 void waypt_flush_all(void);
 unsigned int waypt_count(void);
 void free_gpx_extras (xml_tag * tag);
+void xcsv_setup_internal_style(const char *style_buf);
 void xcsv_read_internal_style(const char *style_buf);
 waypoint * find_waypt_by_name(const char *name);
 
index 3bfac7257cd38032aa9a7a5c1acef05f93d3e586..a94e12f8a43ac28c416f75bbeee2b4d0bbd30d5a 100644 (file)
@@ -378,6 +378,7 @@ find_vec(char *const vecname, char **opts)
                        }
                }
 
+               xcsv_setup_internal_style( NULL );
                xfree(v);
                return vec->vec;
                
@@ -407,7 +408,7 @@ find_vec(char *const vecname, char **opts)
                } else {
                        *opts = NULL;
                }
-               xcsv_read_internal_style(svec->style_buf);
+               xcsv_setup_internal_style(svec->style_buf);
 
                xfree(v);
 
index fe22c83dc0b2372f3e03beecaec27923e867f1c5..da695a1e825086ee53e4406c48b5cd9d3c182b45 100644 (file)
@@ -38,6 +38,8 @@ static char *snuniqueopt = NULL;
 char *prefer_shortnames = NULL;
 char *xcsv_urlbase = NULL;
 
+static const char *intstylebuf = NULL;
+
 static
 arglist_t xcsv_args[] = {
        {"style", &styleopt, "Full path to XCSV style file", NULL,
@@ -83,6 +85,7 @@ xcsv_destroy_style(void)
     queue *elem, *tmp;
     field_map_t *fmp;
     ogue_t *ogp;
+    int internal = 0;
 
     /* 
      * If this xcsv_file struct came from a file we can free it all.
@@ -158,7 +161,9 @@ xcsv_destroy_style(void)
         xfree(xcsv_file.mkshort_handle);
 
     /* return everything to zeros */
+    internal = xcsv_file.is_internal;
     memset(&xcsv_file, '\0', sizeof(xcsv_file));
+    xcsv_file.is_internal = internal;
 }
 
 static const char *
@@ -462,6 +467,15 @@ xcsv_read_internal_style(const char *style_buf)
        }
 }
 
+void
+xcsv_setup_internal_style(const char *style_buf)
+{
+       xcsv_file_init();
+       xcsv_file.is_internal = !!style_buf;
+       intstylebuf = style_buf;
+}
+
+
 static void
 xcsv_rd_init(const char *fname)
 {
@@ -470,7 +484,10 @@ xcsv_rd_init(const char *fname)
      * if we don't have an internal style defined, we need to
      * read it from a user-supplied style file, or die trying.
      */
-    if (xcsv_file.is_internal == 0) {
+    if (xcsv_file.is_internal ) {
+       xcsv_read_internal_style( intstylebuf );
+    }
+    else {
         if (!styleopt)
             fatal(MYNAME ": XCSV input style not declared.  Use ... -i xcsv,style=path/to/file.style\n");
 
@@ -495,7 +512,10 @@ xcsv_wr_init(const char *fname)
     /* if we don't have an internal style defined, we need to
      * read it from a user-supplied style file, or die trying.
      */
-    if (xcsv_file.is_internal == 0) {
+    if (xcsv_file.is_internal ) {
+       xcsv_read_internal_style( intstylebuf );
+    }
+    else {
 
         if (!styleopt)
             fatal(MYNAME ": XCSV output style not declared.  Use ... -o xcsv,style=path/to/file.style\n");